home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Programming / RJTextEd.exe / {app} / InstallData / Scripts / examples / OptionsForm.cpp < prev    next >
Encoding:
Text File  |  2009-04-26  |  1.5 KB  |  70 lines

  1. TForm f;
  2. TGroupbox g;
  3. TRadioButton rb1,rb2;
  4. TButton b;
  5.  
  6. void ButtonClick(TButton Sender)
  7. {
  8.   if (rb1.Checked)
  9.    ShowMessage("Option 1 was selected");
  10.   else if (rb2.Checked)
  11.    ShowMessage("Option 2 was selected");
  12.   f.ModalResult = mrOk;
  13. }
  14.  
  15. {
  16.    f = new TForm(nil);
  17.    f.Caption = "MyApp...";
  18.    f.BorderStyle = bsSizeable;
  19.    f.Position = poScreenCenter;
  20.    f.Width = 400;
  21.    f.Height = 300;
  22.    int w = f.ClientWidth;
  23.    int h = f.ClientHeight;
  24.    
  25.    // Options ----------------------------
  26.    g = new TGroupBox(f);
  27.    g.Name = "gOptions";
  28.    g.Parent = f;
  29.    g.SetBounds(10, 10, 200, 100);
  30.    g.Anchors = akLeft+akTop;
  31.    g.Caption = "Options";
  32.    
  33.    rb1 = new TRadioButton(g);
  34.    rb1.Name = "rb1";
  35.    rb1.Parent = g;
  36.    rb1.Left = 10;
  37.    rb1.Top = 20;
  38.    rb1.Width = g.Width - 11;
  39.    rb1.Anchors = akLeft+akTop;
  40.    rb1.Caption = "Option 1";
  41.    rb1.Checked = True;
  42.    
  43.    rb2 = new TRadioButton(g);
  44.    rb2.Name = "rb2";
  45.    rb2.Parent = g;
  46.    rb2.Parent = g;
  47.    rb2.Left = 10;
  48.    rb2.Top = rb1.Top + rb1.Height + 5;
  49.    rb2.Width = g.Width - 11;
  50.    rb2.Anchors = akLeft+akTop;
  51.    rb2.Caption = "Option 2"; 
  52.    //-------------------------------------
  53.    
  54.    // Go button
  55.    b = new TButton(f);
  56.    b.Name = "btnGo";
  57.    b.Parent = f;
  58.    b.SetBounds(w - 80, h - 30, 75, 25);
  59.    b.Anchors = akRight+akBottom;
  60.    b.Caption = "Go";
  61.  
  62.    b.OnClick = &ButtonClick; 
  63.    
  64.    // Show the dialog
  65.    f.ShowModal;
  66.    f.Free;
  67.  
  68. }
  69.  
  70.